www.gusucode.com > 地平线cms ASP.NET门户网站系统 v2.x源码程序 > 地平线cms ASP.NET门户网站系统 v2.x/deepsooncmsV2.2/deepsooncmsV2.2/Theme/Default/Js/slideshow.js

    var Slideshow = {
	object: null,timer: null,index: 0,data: [],slides: [],playing: false,lastSlide: null,
    initialize: function(object, data) {
        Slideshow.object = $(object);Slideshow.data = data;Slideshow.slides = Slideshow.object.find('.slide');
		if (Slideshow.slides.length <= 1)
			Slideshow.object.find('.controls, .paging').hide();
		var caption = Slideshow.object.find('.caption');		
		caption.html("");caption.append('<a href="'+ data[0].url +'" class="link">'+ data[0].title +'</a>');		
		Slideshow.object.find('.preBut').hide();
		Slideshow.object.find('.nextBut').hide();
		Slideshow.play();
    },
	fade: function(index) {
		Slideshow.slides.stop(true, true).fadeOut(1000);
		Slideshow.slides.eq(index).fadeIn(1000);		
		var caption = Slideshow.object.find('.caption');
		if (Slideshow.data[index]) {
			caption.html("");caption.append('<a href="'+ Slideshow.data[index].url +'" class="link">'+ Slideshow.data[index].title +'</a>');
			//caption.fadeIn(1500);
		}
		Slideshow.lastSlide = index;
	},
    jump: function(index, control) {
		if ((Slideshow.lastSlide == index) || (Slideshow.slides.length <= 1))return;
        Slideshow.pause();Slideshow.fade(index);Slideshow.index = index;Slideshow.object.find('.paging span').removeClass('current');$(control).addClass('current');
    },
    play: function() {if (Slideshow.slides.length <= 1)return;if (!Slideshow.playing) {Slideshow.playing = true;Slideshow.timer = window.setInterval(Slideshow.rotate,5000);}
    },
    pause: function() {if (Slideshow.slides.length <= 1)return;window.clearInterval(Slideshow.timer);Slideshow.playing = false;
	},
	preBut: function() {
		Slideshow.pause();
		Slideshow.index = Slideshow.index-1;
		if(Slideshow.index < 0)Slideshow.index = Slideshow.slides.length - 1;
		Slideshow.fade(Slideshow.index);
		Slideshow.object.find('.paging span').removeClass('current');
		Slideshow.object.find('.paging span:eq('+ Slideshow.index +')').addClass('current');
	},
	showBut: function() {
		Slideshow.object.find('.preBut').show();
		Slideshow.object.find('.nextBut').show();
	},
	hideBut: function() {
		Slideshow.object.find('.preBut').hide();
		Slideshow.object.find('.nextBut').hide();
	},
	nextBut: function(control) {
		Slideshow.pause();
		Slideshow.index = Slideshow.index+1;
		if(Slideshow.index > Slideshow.slides.length - 1)Slideshow.index = 0;
		Slideshow.fade(Slideshow.index);
		Slideshow.object.find('.paging span').removeClass('current');
		Slideshow.object.find('.paging span:eq('+ Slideshow.index +')').addClass('current');
	},
	rotate: function() {var slideIndex = Slideshow.index + 1;if (slideIndex > (Slideshow.slides.length - 1))slideIndex = 0;
		if (Slideshow.lastSlide == slideIndex)return;Slideshow.fade(slideIndex);Slideshow.index = slideIndex;
        Slideshow.object
			.find('.paging span').removeClass('current').end()
			.find('.paging span:eq('+ slideIndex +')').addClass('current');
    }
};